# submit 方法：用于提交，进入线程池
# - running()
# - done()
import time
import random
from concurrent.futures import ThreadPoolExecutor


def eat(name):
    print(f'{name} is eating')
    time.sleep(random.randint(5, 10))
    print(f'{name} is done')
    return f"{name} 's result"


if __name__ == '__main__':
    with ThreadPoolExecutor(max_workers=5) as executor:
        # executor.submit(eat, 1)
        # executor.submit(eat, 2)
        # executor.submit(eat, 3)
        req = [executor.submit(eat, name) for name in range(10)]
        print(req)  # future对象
        for fs in req:
            print('运行状态---', fs.running())
            print('是否完成---', fs.done())
